package com.zzl.springboot_mybatis_demo.filter;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * description: 请求过滤器
 * @author 朱正磊
 * @date 2019-12-09 13:59:37
 */
@Slf4j
public class RequestFilter implements Filter {

    /**
     * description: 初始化方法
     * @author 朱正磊
     * @date 2019-12-09 14:01:08
     * @param filterConfig 过滤器配置
     * @throws ServletException Servlet异常
     */
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        // TODO: 2019-12-09 暂时不做处理
    }

    /**
     * description: 具体业务过滤
     * @author 朱正磊
     * @date 2019-12-09 14:02:14
     * @param req 请求对象
     * @param res 响应对象
     * @param chain 过滤链
     * @throws IOException IO异常
     * @throws ServletException Servlet异常
     */
    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) res;
        // TODO: 2019-12-10 具体业务逻辑待完善
        chain.doFilter(request, response);
    }

    /**
     * description: 销毁方法
     * @author 朱正磊
     * @date 2019-12-09 14:01:57
     */
    @Override
    public void destroy() {
        // TODO: 2019-12-09 暂时不做处理
    }

}
